package com.tjec.project.system.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.tjec.framework.aspectj.lang.annotation.Excel;
import com.tjec.framework.web.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

/**
 * 用户对象 sys_user
 *
 * @author tjec
 */
public class SysUser extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    @ApiModelProperty("用户id")
    private String userId;
    
    private String guid;

    /**
     * 用户全局ID
     */
    @ApiModelProperty("用户全局id")
    private String globalId;

    /**
     * 姓名
     */
    @Excel(name = "姓名")
    @ApiModelProperty("姓名")
    private String nickName;
    
    /**
     * 员工编号
     */
    @Excel(name = "员工编号")
    @ApiModelProperty("员工编号")
    private String jobNo;
    
    /**
     * 用户账号
     */
    @Excel(name = "账号")
    @ApiModelProperty("账号")
    //@Excel(name = "用户账号")
    private String userName;

    /**
     * 手机号码
     */
    @Excel(name = "手机号码")
    @ApiModelProperty("手机号码")
    private String phonenumber;

    /**
     * 所属角色
     */
    @Excel(name = "所属角色")
    @ApiModelProperty("所属角色")
    private String userRoles;
    
    /**所属项目负责人**/
    @Excel(name = "所属项目负责人")
    private String leaders;
   
    /**
     * 人事主管部门
     */
    @Excel(name = "人事主管部门")
    @ApiModelProperty("人事主管部门")
    private String personnelDept;
    
    /**
     * 帐号状态（0正常 1停用 2未启用）
     */
    @Excel(name = "状态", readConverterExp = "0=正常,1=停用,2=未启用")
    @ApiModelProperty("账号状态，0=正常,1=停用,2=未启用")
    private String status;
    
    @Excel(name = "备注")
    private String remark;

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	/**
     * 用户类型
     */
    
    @ApiModelProperty("用户类型")
    private String userType;

    /**
     * 用户邮箱
     */
   
    @ApiModelProperty("用户邮箱")
    private String email;

    /**
     * 用户性别
     */
    
    @ApiModelProperty("用户性别，0=男,1=女,2=未知")
    private String sex;

    /**
     * 密码
     */
    @JsonIgnore
    @ApiModelProperty("密码")
    private String password;

    /**
     * 删除标志 删除标志（0代表存在 2代表删除）
     */
    private String delFlag;
     
    

    /**
     * 用户头像
     */
    @ApiModelProperty("用户头像")
    private String avatar;

     /**
      * bpm用户id
      */
     private String bpmUserId;

    public String getUserRoles() {
        return userRoles;
    }

    public void setUserRoles(String userRoles) {
        this.userRoles = userRoles;
    }

    /**
     * 最后登陆IP
     */
    
    private String loginIp;

    /**
     * 最后登陆时间
     */
    
    private Date loginDate;

    /**
     * 角色对象
     */
    private List<SysRole> roles;

    /**
     * 角色组
     */
    private String[] roleIds;

    /**
     * 岗位组
     */
    private String[] postIds;
    
    /**
     * 部门技术负责人
     */
    private String[] deptIds;
    
    /**
     * 所技术负责人
     */
    private String[] instituteDeptIds;
    
    /**
     * 专业技术负责人
     */
    private String[] businessTypeIds;
    
    /**
     * 公章管理员
     */
    private String[] cachetDeptIds;
    
    /**
     * 业务分管副总
     */
    private String[] businessDeptIds;
    
    /**
     * 部领导
     */
    private String[] deptLeaderIds;
    
    /**
     * 所领导
     */
    private String[] deptInstituteLeaderIds;
    
    public String[] getDeptIds() {
		return deptIds;
	}

	public void setDeptIds(String[] deptIds) {
		this.deptIds = deptIds;
	}

	public String[] getBusinessTypeIds() {
		return businessTypeIds;
	}

	public void setBusinessTypeIds(String[] businessTypeIds) {
		this.businessTypeIds = businessTypeIds;
	}

	public String[] getCachetDeptIds() {
		return cachetDeptIds;
	}

	public void setCachetDeptIds(String[] cachetDeptIds) {
		this.cachetDeptIds = cachetDeptIds;
	}

	public String[] getBusinessDeptIds() {
		return businessDeptIds;
	}

	public void setBusinessDeptIds(String[] businessDeptIds) {
		this.businessDeptIds = businessDeptIds;
	}

	public String[] getDeptLeaderIds() {
		return deptLeaderIds;
	}

	public void setDeptLeaderIds(String[] deptLeaderIds) {
		this.deptLeaderIds = deptLeaderIds;
	}

	public void setOpenProjectLeader(boolean isOpenProjectLeader) {
		this.isOpenProjectLeader = isOpenProjectLeader;
	}

	/**
     * 项目负责人工作台菜单是否开窗
     */
    private boolean isOpenProjectLeader;

    public boolean getIsOpenProjectLeader() {
        return isOpenProjectLeader;
    }

    public void setIsOpenProjectLeader(boolean openProjectLeader) {
        isOpenProjectLeader = openProjectLeader;
    }

    public SysUser() {

    }

    public SysUser(String userId) {
        this.userId = userId;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public boolean isAdmin() {
        return isAdmin(this.userId);
    }

    public static boolean isAdmin(String userId) {
        return userId != null && "61c22bb0-82e8-11ea-b423-00163e0c795f".equals(userId);
    }

    public String getGlobalId() {
        return globalId;
    }

    public void setGlobalId(String globalId) {
        this.globalId = globalId;
    }

    public String getPersonnelDept() {
        return personnelDept;
    }

    public void setPersonnelDept(String personnelDept) {
        this.personnelDept = personnelDept;
    }

    public String getJobNo() {
        return jobNo;
    }

    public void setJobNo(String jobNo) {
        this.jobNo = jobNo;
    }

    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }

    @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    @NotBlank(message = "用户账号不能为空")
    @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Email(message = "邮箱格式不正确")
    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
    public String getPhonenumber() {
        return phonenumber;
    }

    public void setPhonenumber(String phonenumber) {
        this.phonenumber = phonenumber;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    @JsonProperty
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }


    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public String getLoginIp() {
        return loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }

    public Date getLoginDate() {
        return loginDate;
    }

    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }

    public List<SysRole> getRoles() {
        return roles;
    }

    public void setRoles(List<SysRole> roles) {
        this.roles = roles;
    }

    public String[] getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(String[] roleIds) {
        this.roleIds = roleIds;
    }

    public String[] getPostIds() {
        return postIds;
    }

    public void setPostIds(String[] postIds) {
        this.postIds = postIds;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("userId", getUserId())
                .append("userName", getUserName())
                .append("globalId", getGlobalId())
                .append("nickName", getNickName())
                .append("personnelDept", getPersonnelDept())
                .append("jobNo", getJobNo())
                .append("userType", getUserType())
                .append("email", getEmail())
                .append("phonenumber", getPhonenumber())
                .append("sex", getSex())
                .append("avatar", getAvatar())
                .append("password", getPassword())
                .append("status", getStatus())
                .append("loginIp", getLoginIp())
                .append("loginDate", getLoginDate())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .append("remark", getRemark())
                .append("userRoles", getUserRoles())
                .append("guid", getGuid())
                .append("deptIds", getDeptIds())
                .append("businessTypeIds", getBusinessTypeIds())
                .append("cachetDeptIds", getCachetDeptIds())
                .append("businessDeptIds", getBusinessDeptIds())
                .append("deptLeaderIds", getDeptLeaderIds())
                .append("instituteDeptIds", getInstituteDeptIds())
                .append("deptInstituteLeaderIds", getDeptInstituteLeaderIds())
                .append("leaders", getLeaders())
                .append("bpmUserId", getBpmUserId())
                .toString();
        
    }

	public String getGuid() {
		return guid;
	}

	public void setGuid(String guid) {
		this.guid = guid;
	}

	public String[] getInstituteDeptIds() {
		return instituteDeptIds;
	}

	public void setInstituteDeptIds(String[] instituteDeptIds) {
		this.instituteDeptIds = instituteDeptIds;
	}

	public String[] getDeptInstituteLeaderIds() {
		return deptInstituteLeaderIds;
	}

	public void setDeptInstituteLeaderIds(String[] deptInstituteLeaderIds) {
		this.deptInstituteLeaderIds = deptInstituteLeaderIds;
	}

	public String getLeaders() {
		return leaders;
	}

	public void setLeaders(String leaders) {
		this.leaders = leaders;
	}

	public String getBpmUserId() {
		return bpmUserId;
	}

	public void setBpmUserId(String bpmUserId) {
		this.bpmUserId = bpmUserId;
	}
}
